package com.jlpay.openapi.demo.trans.common;

import com.jlpay.open.jlpay.sdk.java.model.trans.common.request.AuthCompleteRefundRequest;
import com.jlpay.open.jlpay.sdk.java.model.trans.common.response.AuthCompleteRefundResponse;
import com.jlpay.open.jlpay.sdk.java.utils.json.JsonUtils;
import com.jlpay.openapi.demo.JlpayOpenApiService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 *
 * @author dengwenning
 * @since 2024/9/23
 **/
public class AuthCompleteRefundService {
    private static final Logger LOGGER = LoggerFactory.getLogger(AuthCompleteRefundService.class);

    public static void main(String[] args) {
        AuthCompleteRefundRequest authCompleteRefundRequest = buildAuthCompleteRefundRequest();
        AuthCompleteRefundResponse authCompleteRefundResponse = JlpayOpenApiService.openMerchService()
                .post(authCompleteRefundRequest, AuthCompleteRefundResponse.class);
        LOGGER.info("预授权完成退款响应:{}", JsonUtils.toString(authCompleteRefundResponse));
    }

    private static AuthCompleteRefundRequest buildAuthCompleteRefundRequest() {
        AuthCompleteRefundRequest authCompleteRefundRequest = new AuthCompleteRefundRequest();

        authCompleteRefundRequest.setMchId("849584358120018");
        authCompleteRefundRequest.setTermNo("60131234");
        authCompleteRefundRequest.setOutTradeNo("ld201911023465529");
        authCompleteRefundRequest.setOriOutTradeNo("ld2019102216465525");
        authCompleteRefundRequest.setOriTransactionId("80011557201909171853011568");
        authCompleteRefundRequest.setTotalFee("1");
        authCompleteRefundRequest.setRemark("该订单物流请走顺丰快递");
        authCompleteRefundRequest.setDeviceInfo("N50007A8890");
        authCompleteRefundRequest.setMchCreateIp("123.12.12.123");
        authCompleteRefundRequest.setTransAddress("深圳市南山区科技二路10号");
        authCompleteRefundRequest.setAreaCode("4403");
        authCompleteRefundRequest.setLongitude("116.078631");
        authCompleteRefundRequest.setLatitude("39.71274");

        return authCompleteRefundRequest;
    }
}
